home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
CallStack.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
4KB
|
166 lines
class CallStack extends Array
{
static var runningStacks = [];
static var STOP_STACK = 1.7976931348623157e+308;
var className = "CallStack";
var updateInterval = 0;
var paused = false;
var running = false;
var index = 0;
function CallStack()
{
super();
}
static function pauseAll()
{
var _loc1_ = CallStack.runningStacks.length;
while((_loc1_ = _loc1_ - 1) > -1)
{
CallStack.runningStacks[_loc1_].pause();
}
return false;
}
static function unpauseAll()
{
var _loc1_ = CallStack.runningStacks.length;
while((_loc1_ = _loc1_ - 1) > -1)
{
CallStack.runningStacks[_loc1_].unpause();
}
}
static function stopAll()
{
var _loc1_ = CallStack.runningStacks.length;
while((_loc1_ = _loc1_ - 1) > -1)
{
CallStack.runningStacks[_loc1_].stop();
}
return false;
}
static function buildCall(target, method)
{
var _loc2_ = arguments.slice(2);
_loc2_.target = target;
_loc2_.method = method;
return _loc2_;
}
function call(target, method)
{
this.push(CallStack.buildCall.apply(this,arguments));
}
function wait(seconds)
{
this.call(this,this.startCountDown,seconds);
}
function startCountDown(seconds)
{
this.lastTime = getTimer() * 0.001;
this.countdowntime = seconds;
return this.countdown;
}
function countdown()
{
this.countdowntime += this.lastTime - (this.lastTime = getTimer() * 0.001);
return this.countdowntime <= 0;
}
function waitUntilEqual(target, property, targetValue)
{
this.call(target,this.untilEqual,property,targetValue);
}
function untilEqual(property, targetValue)
{
return this[property] == targetValue;
}
function start()
{
if(this.running)
{
return undefined;
}
this.running = true;
CallStack.runningStacks.push(this);
this.index = 0;
this.intervalID = setInterval(function(o)
{
o.update();
}
,this.updateInterval,this);
}
function stop()
{
clearInterval(this.intervalID);
var _loc2_ = CallStack.runningStacks.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
if(CallStack.runningStacks[_loc2_] == this)
{
CallStack.runningStacks.splice(_loc2_,1);
}
}
this.running = false;
return false;
}
function finish()
{
this.onFinish();
this.stop();
}
function pause()
{
this.paused = true;
return false;
}
function resume()
{
this.lastTime = getTimer() * 0.001;
this.paused = false;
}
function update()
{
if(this.paused)
{
return false;
}
var _loc3_ = this[this.index];
var _loc2_ = _loc3_.method.apply(_loc3_.target,_loc3_);
switch(typeof _loc2_)
{
case "function":
_loc3_.method = _loc2_;
break;
case "object":
if(_loc2_.className == "CallStack")
{
this.splice(this.index,1,CallStack.buildCall(_loc2_,_loc2_.update));
}
else if(_loc2_.length != null)
{
this.splice(this.index,1,_loc2_);
}
break;
default:
if(_loc2_ || _loc2_ == null)
{
this.index = _loc0_ = this.index + 1;
if(_loc0_ > this.length)
{
this.finish();
return true;
}
break;
}
if(_loc2_ == CallStack.STOP_STACK)
{
stop();
break;
}
break;
}
return false;
}
function toString()
{
return "Call Stack";
}
}